package com.ljb.readaloud.v;

import android.os.Bundle;
import android.os.SystemClock;
import android.support.annotation.Nullable;

import com.ljb.readaloud.base.BaseActivity;
import com.yanzhenjie.permission.Action;
import com.yanzhenjie.permission.AndPermission;
import com.yanzhenjie.permission.Permission;

import java.util.List;

/**
 * Created by ljb on 2018/3/26.
 */

public class SplashActivity extends BaseActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

//        new Thread() {
//            @Override
//            public void run() {
//                super.run();
//                SystemClock.sleep(3000);
//                requestPermission();
//            }
//        }.start();
        requestPermission();
    }

    private void requestPermission() {
        AndPermission.with(this)
                .permission(Permission.Group.STORAGE, Permission.Group.MICROPHONE)
                .onGranted(new Action() {
                    @Override
                    public void onAction(List<String> permissions) {//同意授权
                        MainActivity.actionStart(SplashActivity.this);
                        finish();
                    }
                })
                .onDenied(new Action() {
                    @Override
                    public void onAction(List<String> permissions) {//拒绝授权
                        finish();
                    }
                })
                .start();
    }
}
